package com.jiutong.meipenggang.http.present;

import android.content.Context;
import android.util.Log;

import com.jiutong.meipenggang.common.Constants;
import com.jiutong.meipenggang.entity.MineFramentInfoBean;
import com.jiutong.meipenggang.http.model.interfaces.BaseBiz;
import com.jiutong.meipenggang.http.model.requests.MineFramentRequest;
import com.jiutong.meipenggang.http.subscribers.ProgressSubscriber;
import com.jiutong.meipenggang.http.subscribers.SubscriberOnNextListener;
import com.jiutong.meipenggang.utils.SpConfig;

import java.util.HashMap;

/**
 * @author Veken
 * @date on 2017/12/19 9:57
 * @describe
 */

public class MineFramentInfoPresent  {

    private Context mContext;
    private MineFramentRequest mineFramentRequest;
    private BaseBiz baseBiz;

    public MineFramentInfoPresent(Context mContext,BaseBiz baseBiz) {
        this.mContext = mContext;
        this.mineFramentRequest = new MineFramentRequest();
        this.baseBiz = baseBiz;
    }

    public void getMineFramentInfo(){
        SubscriberOnNextListener onNextListener = new SubscriberOnNextListener<MineFramentInfoBean>() {
            @Override
            public void onNext(MineFramentInfoBean object) {
                baseBiz.onSuccess(object);
            }

            @Override
            public void onError(Throwable e) {
                baseBiz.onError(e);
            }
        };
        HashMap<String,Object> fieldMap = new HashMap<>();
        fieldMap.put("OPT",101);
        fieldMap.put("id", SpConfig.getInstance().getString(Constants.ID));
        Log.d("TAG",SpConfig.getInstance().getString(Constants.TOKEN));
        fieldMap.put("token",SpConfig.getInstance().getString(Constants.TOKEN));
        mineFramentRequest.getMineInfo(new ProgressSubscriber(onNextListener,mContext),fieldMap);
    }
}
